home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-12 | 22.4 KB | 1,161 lines | [TEXT/CWIE] |
- #ifndef DEBUG_DRIVER
- #define DEBUG_DRIVER 0
- #endif
-
- #include <stdio.h>
- #include <stdlib.h>
-
- #include <DeskBus.h>
-
- #include "InputSprocket.h"
- #include "SIOUX.h"
- #include <CursorDevices.h>
- #include <LowMem.h>
-
- #if DEBUG_DRIVER
- #include "InputSprocketDriver.h"
- #endif
-
- enum
- {
- kNeedCount = 9
- };
-
- enum
- {
- kIconSuiteID_XThrust = 128,
- kIconSuiteID_YThrust,
- kIconSuiteID_ZThrust,
- kIconSuiteID_Look,
- kIconSuiteID_Fire,
- kIconSuiteID_Thrust,
- kIconSuiteID_Pause,
- kIconSuiteID_Start,
- kIconSuiteID_Scroll
- };
-
- Boolean gIsSuspended = false;
- Boolean gKeyboardEnabled = false;
- ISpElementListReference gVirtualList = NULL;
- ISpElementReference gVirtualElements[kNeedCount] = {nil, nil, nil, nil, nil, nil, nil, nil, nil};
-
-
-
- static ISpNeed gNeeds[kNeedCount] =
- {
- { "\pForward Thrust", kIconSuiteID_YThrust, 0, kISpElementKind_Axis, kISpElementLabel_YAxis, 0 },
- { "\pSide Thrust", kIconSuiteID_XThrust, 0, kISpElementKind_Axis, kISpElementLabel_XAxis, 0 },
- { "\pVertical Thrust", kIconSuiteID_ZThrust, 0, kISpElementKind_Axis, kISpElementLabel_ZAxis, 0 },
- { "\pLook", kIconSuiteID_Look, 0, kISpElementKind_Movement, kISpElementLabel_None, 0 },
- { "\pFire", kIconSuiteID_Fire, 0, kISpElementKind_Button, kISpElementLabel_Fire, 0 },
- { "\pThrust", kIconSuiteID_Thrust, 0, kISpElementKind_Button, kISpElementLabel_Fire, 0 },
- { "\pPause", kIconSuiteID_Pause, 0, kISpElementKind_Button, kISpElementLabel_None, kISpNeedFlag_NoMultiConfig },
- { "\pStart/Stop", kIconSuiteID_Start, 0, kISpElementKind_Button, kISpElementLabel_Start, kISpNeedFlag_NoMultiConfig },
- { "\pScroll", kIconSuiteID_Scroll, 0, kISpElementKind_DPad, kISpElementLabel_None, 0 }
- };
-
-
- void ShowFourByte(OSType fourByte);
- void ShowFourByte(OSType fourByte)
- {
- putchar(((fourByte & 0xff000000) >> 24));
- putchar(((fourByte & 0x00ff0000) >> 16));
- putchar(((fourByte & 0x0000ff00) >> 8));
- putchar(((fourByte & 0x000000ff) >> 00));
- }
-
- void ShowStr63(const Str63 &theStr);
- void ShowStr63(const Str63 &theStr)
- {
- int i;
- int len = theStr[0];
- if (len > 63) { len = 63; }
-
- for(i=1; i <= len; i++)
- {
- putchar(theStr[i]);
- }
- }
-
-
- void PrintEvent(ISpElementEventPtr theEvent);
- void PrintEvent(ISpElementEventPtr theEvent)
- {
- ISpElementInfo info;
- ISpElement_GetInfo(theEvent->element, &info);
- OSStatus status;
- const char* s = "•UNKNOWN•";
-
- printf("when = [%lu] [%lu]\n", theEvent->when.hi, theEvent->when.lo);
-
- switch (info.theKind)
- {
- case kISpElementKind_Button:
- switch (theEvent->data)
- {
- case 0:
- s = "released";
- break;
-
- case 1:
- s = "pressed";
- break;
- }
-
- printf("data = 0x%lx (%s)\n", theEvent->data, s);
- break;
-
- case kISpElementKind_DPad:
- switch (theEvent->data)
- {
- case kISpPadIdle:
- s = "kISpPadIdle";
- break;
-
- case kISpPadLeft:
- s = "kISpPadLeft";
- break;
-
- case kISpPadUpLeft:
- s = "kISpPadUpLeft";
- break;
-
- case kISpPadUp:
- s = "kISpPadUp";
- break;
-
- case kISpPadUpRight:
- s = "kISpPadUpRight";
- break;
-
- case kISpPadRight:
- s = "kISpPadRight";
- break;
-
- case kISpPadDownRight:
- s = "kISpPadDownRight";
- break;
-
- case kISpPadDown:
- s = "kISpPadDown";
- break;
-
- case kISpPadDownLeft:
- s = "kISpPadDownLeft";
- break;
- }
-
- printf("data = 0x%lx (%s)\n", theEvent->data, s);
- break;
-
- case kISpElementKind_Axis:
- float temp1 = ((float) theEvent->data)/((float) 0xFFFFFFFFU);
- float temp2 = 2.0*temp1-1.0;
-
- printf("data = 0x%lx (%f%) (%f%)\n", theEvent->data, temp1, temp2);
- break;
-
- case kISpElementKind_Movement:
- printf("data = 0x%lx\n", theEvent->data);
-
- ISpMovementData movementData;
- if (ISpElement_GetComplexState(theEvent->element, sizeof(ISpMovementData), &movementData) == noErr)
- {
- switch (movementData.direction)
- {
- case kISpPadIdle:
- s = "kISpPadIdle";
- break;
-
- case kISpPadLeft:
- s = "kISpPadLeft";
- break;
-
- case kISpPadUpLeft:
- s = "kISpPadUpLeft";
- break;
-
- case kISpPadUp:
- s = "kISpPadUp";
- break;
-
- case kISpPadUpRight:
- s = "kISpPadUpRight";
- break;
-
- case kISpPadRight:
- s = "kISpPadRight";
- break;
-
- case kISpPadDownRight:
- s = "kISpPadDownRight";
- break;
-
- case kISpPadDown:
- s = "kISpPadDown";
- break;
-
- case kISpPadDownLeft:
- s = "kISpPadDownLeft";
- break;
- }
-
- float horz = 2.0*(((float) movementData.xAxis)/((float) 0xFFFFFFFFU))-1.0;
- float vert = 2.0*(((float) movementData.yAxis)/((float) 0xFFFFFFFFU))-1.0;
-
- printf("state = (%f,%f) (%s)\n", horz, vert, s);
- }
- break;
- }
-
- printf("element = 0x%lx\n", theEvent->element);
- printf("refcon = %lx\n", theEvent->refCon);
-
- printf("label = ");
- ShowFourByte(info.theLabel);
- printf("\n");
-
- printf("kind = ");
- ShowFourByte(info.theKind);
- printf("\n");
-
- printf("string = ");
- ShowStr63(info.theString);
- printf("\n");
-
- {
- UInt32 data;
-
- status = ISpElement_GetSimpleState(theEvent->element, &data);
-
- if (status == noErr) { printf("polled = %x\n",data); }
- }
-
- printf("\n\n");
- }
-
-
- void PrintElementBlock(ISpElementReference *theElementReferences, UInt32 count);
- void PrintElementBlock(ISpElementReference *theElementReferences, UInt32 count)
- {
- printf("count = %d\n");
-
- int itr;
-
- for(itr = 0; itr < count; itr++)
- {
- printf(" element #%d\n",itr);
-
- ISpElementInfo info;
-
- ISpElement_GetInfo(theElementReferences[itr], &info);
-
- printf(" label = ");
- ShowFourByte(info.theLabel);
- printf("\n");
-
- printf(" kind = ");
- ShowFourByte(info.theKind);
- printf("\n");
-
- printf(" string = ");
- ShowStr63(info.theString);
- printf("\n\n");
- }
- }
-
- // if whichList is NULL then we use the global list
- static void GetAndPrintEvents(ISpElementListReference whichList)
- {
- OSErr err;
-
- if (whichList == NULL)
- {
- err = ISpGetGlobalElementList(&whichList);
- if (err)
- {
- printf("••• ISpGetGlobalElementList returned error (%ld)\n",err);
- return;
- }
- }
-
- err = ISpElementList_Flush(whichList);
- if (err)
- {
- printf("••• ISpElementList_Flush returned error (%ld)\n",err);
- return;
- }
-
- printf("getting events (press command to end)\n");
-
- while(1)
- {
- ISpElementEvent event;
- Boolean wasEvent;
-
- err = ISpElementList_GetNextEvent(whichList, sizeof(event), &event, &wasEvent);
- if (err)
- {
- printf("••• ISpElementList_GetNextEvent returned error (%ld)\n",err);
- return;
- }
-
- if (wasEvent)
- {
- PrintEvent(&event);
- }
-
- KeyMap theKeys;
- GetKeys(theKeys);
-
- if ((theKeys[1] & 0x8000))
- {
- break;
- }
-
- SIOUXHandleOneEvent(nil);
- }
- }
-
- static void TestListOfDevices(void)
- {
- ISpDeviceReference theDevices[100];
- UInt32 deviceCount;
- UInt32 deviceBufferSize = 100;
- UInt32 deviceItr;
- OSErr err;
-
- err = ISpDevices_Extract(deviceBufferSize, &deviceCount, theDevices);
- if (err)
- {
- printf("••• ISpDevices_Extract returned error (%ld)\n",err);
- return;
- }
-
- printf("# of devices = %ld\n",deviceCount);
- for(deviceItr = 0; deviceItr < deviceCount; deviceItr++)
- {
- printf(" device #%ld\n",deviceItr);
- ISpDeviceDefinition theDfn;
-
- err = ISpDevice_GetDefinition(theDevices[deviceItr], sizeof(ISpDeviceDefinition), &theDfn);
- if (err)
- {
- printf("••• ISpDevice_GetDefinition returned error (%ld)\n",err);
- return;
- }
-
- printf(" name = ");
- ShowStr63(theDfn.deviceName);
- printf("\n");
-
- printf(" class = ");
- ShowFourByte(theDfn.theDeviceClass);
- printf("\n");
-
- printf(" device identifier = ");
- ShowFourByte(theDfn.theDeviceIdentifier);
- printf("\n");
-
- printf(" permanent id = %ld\n",theDfn.permanentID);
-
- printf("\n\n");
- }
- }
-
-
- static void TestListOfElements(void)
- {
- ISpElementListReference globalList;
- OSErr err;
-
- err = ISpGetGlobalElementList(&globalList);
- if (err)
- {
- printf("••• ISpGetGlobalElementList returned error (%ld)\n",err);
- return;
- }
-
- ISpElementReference theElementReferences[200];
- UInt32 bufferSize = 200;
- UInt32 count;
-
- err = ISpElementList_Extract(globalList, bufferSize, &count, theElementReferences);
- if (err)
- {
- printf("••• ISpElementList_Extract returned error (%ld)\n",err);
- return;
- }
-
- PrintElementBlock(theElementReferences, count);
- }
-
-
- static void TestListOfButtons(void)
- {
- ISpElementListReference globalList;
- OSErr err;
-
- err = ISpGetGlobalElementList(&globalList);
- if (err)
- {
- printf("••• ISpGetGlobalElementList returned error (%ld)\n",err);
- return;
- }
-
- ISpElementReference theElementReferences[200];
- UInt32 bufferSize = 200;
- UInt32 count;
-
- err = ISpElementList_ExtractByKind(globalList, kISpElementKind_Button, bufferSize, &count, theElementReferences);
- if (err)
- {
- printf("••• ISpElementList_Extract returned error (%ld)\n",err);
- return;
- }
-
- PrintElementBlock(theElementReferences, count);
- }
-
-
- static void TestListOfDPads(void)
- {
- ISpElementListReference globalList;
- OSErr err;
-
- err = ISpGetGlobalElementList(&globalList);
- if (err)
- {
- printf("••• ISpGetGlobalElementList returned error (%ld)\n",err);
- return;
- }
-
- ISpElementReference theElementReferences[200];
- UInt32 bufferSize = 200;
- UInt32 count;
-
- err = ISpElementList_ExtractByKind(globalList, kISpElementKind_DPad, bufferSize, &count, theElementReferences);
- if (err)
- {
- printf("••• ISpElementList_Extract returned error (%ld)\n",err);
- return;
- }
-
- PrintElementBlock(theElementReferences, count);
- }
-
-
- static void TestListOfAxes(void)
- {
- ISpElementListReference globalList;
- OSErr err;
-
- err = ISpGetGlobalElementList(&globalList);
- if (err)
- {
- printf("••• ISpGetGlobalElementList returned error (%ld)\n",err);
- return;
- }
-
- ISpElementReference theElementReferences[200];
- UInt32 bufferSize = 200;
- UInt32 count;
-
- err = ISpElementList_ExtractByKind(globalList, kISpElementKind_Axis, bufferSize, &count, theElementReferences);
- if (err)
- {
- printf("••• ISpElementList_Extract returned error (%ld)\n",err);
- return;
- }
-
- PrintElementBlock(theElementReferences, count);
- }
-
-
- static void TestListOfXAxes(void)
- {
- ISpElementListReference globalList;
- OSErr err;
-
- err = ISpGetGlobalElementList(&globalList);
- if (err)
- {
- printf("••• ISpGetGlobalElementList returned error (%ld)\n",err);
- return;
- }
-
- ISpElementReference theElementReferences[200];
- UInt32 bufferSize = 200;
- UInt32 count;
-
- err = ISpElementList_ExtractByLabel(globalList, kISpElementLabel_XAxis, bufferSize, &count, theElementReferences);
- if (err)
- {
- printf("••• ISpElementList_Extract returned error (%ld)\n",err);
- return;
- }
-
- PrintElementBlock(theElementReferences, count);
- }
-
-
- static void TestSuspend(void)
- {
- OSErr err;
-
- err = ISpSuspend();
- if (err)
- {
- printf("••• ISpSuspend returned error (%ld)\n",err);
- return;
- }
-
- gIsSuspended = true;
- }
-
-
- static void TestResume(void)
- {
- OSErr err;
-
- err = ISpResume();
- if (err)
- {
- printf("••• ISpResume returned error (%ld)\n",err);
- return;
- }
-
- gIsSuspended = false;
- }
-
-
- static void TestCreateNeeds(void)
- {
- OSErr err;
-
- if (gVirtualList == NULL)
- {
- printf("creating virtual elements\n");
-
- err = ISpElement_NewVirtualFromNeeds(kNeedCount, gNeeds, gVirtualElements, 0);
- if (err)
- {
- printf("••• ISpElement_NewVirtualFromNeeds returned error (%ld)\n",err);
- return;
- }
-
- err = ISpElementList_New(
- kNeedCount, // count
- gVirtualElements, // needs
- &gVirtualList, // virtual elements
- 0); // flags
- if (err)
- {
- printf("••• ISpElementList_New returned error (%ld)\n",err);
- return;
- }
-
- err = ISpInit(kNeedCount, // count
- gNeeds, // needs
- gVirtualElements, // virtual elements
- 'ISpT', // app
- 'foob', // sub
- 0, // flags
- 128, // set list resource id
- 0); // version
- if (err)
- {
- printf("••• ISpInit returned error (%ld)\n",err);
- return;
- }
- }
- }
-
-
- static void TestDestroyNeeds(void)
- {
- OSErr err;
-
- if (gVirtualList != NULL)
- {
- err = ISpElementList_Dispose(gVirtualList);
- gVirtualList = NULL;
- if (err)
- {
- printf("••• ISpElementList_Dispose returned error (%ld)\n",err);
- return;
- }
-
- err = ISpStop();
- if (err)
- {
- printf("••• ISpStop returned error (%ld)\n",err);
- return;
- }
-
- err = ISpElement_DisposeVirtual(kNeedCount, gVirtualElements);
- if (err)
- {
- printf("••• ISpElement_DisposeVirtual returned error (%ld)\n",err);
- return;
- }
- }
- }
-
-
- static void TestNeedsEvents(void)
- {
- TestCreateNeeds();
-
- if (gVirtualList != NULL)
- {
- GetAndPrintEvents(gVirtualList);
- }
- }
-
-
- static void TestConfiguration(void)
- {
- OSErr err;
-
- TestCreateNeeds();
-
- err = ISpConfigure(nil);
- if (err)
- {
- printf("••• ISpConfigure returned error (%ld)\n",err);
- return;
- }
- }
-
-
- static void EnableDeviceClass(OSType deviceClass, Boolean enable)
- {
- enum {
- kDeviceList_COUNT = 100
- };
-
- OSStatus err;
- UInt32 count;
- ISpDeviceReference deviceList[kDeviceList_COUNT];
-
- // NOTE: This is not the correct way to handle the list count thing. We
- // should actually call once with NULL for the device list, malloc a list of
- // that size, and call again.
-
- err = ISpDevices_ExtractByClass(
- deviceClass,
- kDeviceList_COUNT,
- &count,
- deviceList);
-
- if (err)
- {
- printf("••• ISpDevices_ExtractByClass returned error (%ld)\n",err);
- return;
- }
-
- if (count > kDeviceList_COUNT)
- {
- count = kDeviceList_COUNT;
- }
-
- if (enable)
- {
- err = ISpDevices_Activate(
- count,
- deviceList);
-
- if (err)
- {
- printf("••• ISpDevices_Activate returned error (%ld)\n",err);
- return;
- }
- }
- else
- {
- err = ISpDevices_Deactivate(
- count,
- deviceList);
-
- if (err)
- {
- printf("••• ISpDevices_Deactivate returned error (%ld)\n",err);
- return;
- }
- }
-
- if (deviceClass == kISpDeviceClass_Keyboard)
- {
- gKeyboardEnabled = enable;
- }
- }
-
- static void TestAllocateDeallocate(void)
- {
- OSErr err = noErr;
- UInt32 count = 0;
- char theString[32];
- UInt32 itr;
- ISpElementReference virtuals[kNeedCount];
- Boolean done = false;
-
- printf("allocate/dellocate how many times>");
-
- gets( theString );
- count = atoi( theString );
-
- printf("allocating/deallocating %ld times\n",count);
-
- for(itr = 0; itr < count; itr++)
- {
- if ((itr % 100) == 0) { putchar('.'); fflush(stdout); }
- if ((itr % 1000) == 0)
- {
- long normal = FreeMem();
- long system = FreeMemSys();
- printf("%ld / %ld (app = %ld) (sys = %ld) \n",itr,count,normal,system);
- }
-
- SIOUXHandleOneEvent(nil);
-
- err = ISpElement_NewVirtualFromNeeds(kNeedCount, gNeeds, virtuals, 0);
-
- if (err)
- {
- printf("••• itr = %d ISpElement_NewVirtualFromNeeds returned error (%ld)\n",itr, err);
-
- done = true;
- }
-
- err = ISpElement_DisposeVirtual(kNeedCount, virtuals);
-
- if (err)
- {
- printf("••• ISpElementList_Dispose returned error (%ld)\n",err);
- return;
- }
-
- if (done) { return; }
- }
- }
-
- #define MAX_ELEMENTS 1000
- #define MAX_DATASIZE 1000
-
-
- #if DEBUG_DRIVER
- static void TestAllocatePushData(void)
- {
- char theString[32];
- OSErr err = noErr;
- UInt32 elementCount = 0;
- UInt32 dataSize;
- UInt32 count;
- UInt32 elemItr, itr;
- ISpElementReference elements[MAX_ELEMENTS];
- UInt8 state[MAX_DATASIZE];
-
- printf("how many elements>");
- gets( theString );
- elementCount = atoi( theString );
-
- printf("data size>");
- gets( theString );
- dataSize = atoi( theString );
-
- printf("count>");
- gets( theString );
- count = atoi( theString );
-
- printf("%ld elements, data size = %ld, count = %ld\n", elementCount, dataSize, count);
-
-
- if ((elementCount > MAX_ELEMENTS) || (dataSize > MAX_DATASIZE))
- {
- printf("••• MAX_ELEMENTS = %d MAX_DATASIZE = %d\n",MAX_ELEMENTS,MAX_DATASIZE);
- return;
- }
-
- for(elemItr = 0; elemItr < elementCount; elemItr++)
- {
- err = ISpElement_NewVirtual(dataSize, &(elements[elemItr]), 0);
-
- if (err)
- {
- printf("••• ISpElement_NewVirtual returned error (%d)\n",err);
-
- err = ISpElement_DisposeVirtual(elemItr, elements);
- if (err)
- {
- printf("••• ISpElement_DisposeVirtual returned error (%d)\n",err);
- }
-
- return;
- }
- }
-
- for(itr = 0; itr < count; itr++)
- {
- AbsoluteTime time = {0, TickCount() };
-
- if ((itr % 100) == 0) { printf("."); }
- if ((itr % 1000) == 0)
- {
- long normal = FreeMem();
- long system = FreeMemSys();
- Ptr temp = NewPtr(1000);
- DisposePtr(temp);
- printf("%ld / %ld (app = %ld) (sys = %ld) \n",itr,count,normal,system);
-
- }
-
- SIOUXHandleOneEvent(nil);
-
- for(elemItr = 0; elemItr < elementCount; elemItr++)
- {
- err = ISpElement_PushComplexData(elements[elemItr], dataSize, &state, &time);
-
- if (err)
- {
- printf("••• ISpElement_PushComplexData returned error (%d)\n",err);
- return;
- }
- }
- }
-
- printf("\ndisposing elements\n");
- err = ISpElement_DisposeVirtual(elementCount, elements);
- if (err)
- {
- printf("••• ISpElement_DisposeVirtual returned error (%d)\n",err);
- }
- }
- #endif /* DEBUG_DRIVER */
-
- static void TestArbitraryAllocate(void)
- {
- char theString[32];
- OSErr err = noErr;
- UInt32 elementCount = 0;
- UInt32 dataSize;
- UInt32 elemItr;
- ISpElementReference elements[MAX_ELEMENTS];
-
- printf("how many elements>");
- gets( theString );
- elementCount = atoi( theString );
-
- printf("data size>");
- gets( theString );
- dataSize = atoi( theString );
-
-
- printf("%ld elements, data size = %ld\n", elementCount, dataSize);
-
- if ((elementCount > MAX_ELEMENTS) || (dataSize > MAX_DATASIZE))
- {
- printf("••• MAX_ELEMENTS = %d MAX_DATASIZE = %d\n",MAX_ELEMENTS,MAX_DATASIZE);
- return;
- }
-
- printf("allocating elements\n");
- for(elemItr = 0; elemItr < elementCount; elemItr++)
- {
- err = ISpElement_NewVirtual(dataSize, &(elements[elemItr]), 0);
-
- if (err)
- {
- printf("••• ISpElement_NewVirtual returned error (%d)\n",err);
-
- err = ISpElement_DisposeVirtual(elemItr, elements);
- if (err)
- {
- printf("••• ISpElement_DisposeVirtual returned error (%d)\n",err);
- }
-
- return;
- }
- }
-
- printf("\ndisposing elements\n");
- err = ISpElement_DisposeVirtual(elementCount, elements);
- if (err)
- {
- printf("••• ISpElement_DisposeVirtual returned error (%d)\n",err);
- }
- }
-
- #define MTemp 0x828
- #define RawMouse 0x82c
- #define CrsrNewCouple 0x8ce
-
-
-
-
-
- void TestAcceleration(void);
- void TestAcceleration(void)
- {
- TestCreateNeeds();
-
- ShowCursor();
- Point where = * ( Point * ) RawMouse;
-
- float deltaX = 0;
- float deltaY = 0;
-
- while(1)
- {
- gVirtualElements[0];
- gVirtualElements[1];
-
- UInt32 forward;
- UInt32 side;
- OSStatus status;
- float temp;
- SInt8 amt;
-
- status = ISpElement_GetSimpleState(gVirtualElements[1], &forward);
-
- if (status == noErr)
- {
- temp = forward;
- temp -= kISpAxisMiddle;
- temp /= kISpAxisMiddle;
- temp *= 25;
-
- deltaX += temp;
-
- if (deltaX >= 1)
- {
- amt = deltaX;
- where.h += amt;
- deltaX -= amt;
- }
- else if (deltaX <= -1)
- {
- amt = -deltaX;
- where.h -= amt;
- deltaX += amt;
- }
- }
-
- status = ISpElement_GetSimpleState(gVirtualElements[0], &side);
-
- if (status == noErr)
- {
- temp = side;
- temp -= kISpAxisMiddle;
- temp /= kISpAxisMiddle;
- temp *= -25;
-
- deltaY += temp;
-
- if (deltaY >= 1)
- {
- amt = deltaY;
- where.v += amt;
- deltaY -= amt;
- }
- else if (deltaY <= -1)
- {
- amt = -deltaY;
- where.v -= amt;
- deltaY += amt;
- }
-
- }
-
- HideCursor();
-
- * ( Point * ) RawMouse = where ;
- * ( Point * ) MTemp = where ;
- * ( short * ) CrsrNewCouple = -1 ;
-
- ShowCursor();
-
- KeyMap theKeys;
- GetKeys(theKeys);
-
- if ((theKeys[1] & 0x8000))
- {
- break;
- }
-
- unsigned long aLong = ::TickCount();
-
- while (aLong == TickCount()) { ; }
- }
- }
-
- void main(void)
- {
- // tell SIOUX to shut up
- SIOUXSettings.autocloseonquit = true;
- SIOUXSettings.asktosaveonclose = false;
-
- printf("starting up...\n");
-
- Boolean theDoneFlag = false;
-
- while( !theDoneFlag )
- {
- UInt32 theChoice;
-
- printf("\n\n\n############################################################\n");
- if (gIsSuspended)
- {
- printf("• SUSPENDED •\n");
- }
-
- if (gVirtualList != NULL)
- {
- printf("• NEEDS ARE ACTIVE •\n");
- }
-
- printf("Please select from the following tests:\n");
- printf("\t 1. Exit\n");
- // printf("\t 2. Run all tests automatically\n");
- // printf("\t 3. Dump information needed for InputSprocket bug reports\n");
- printf("\t 4. List all devices\n");
- printf("\t 5. List all elements\n");
- printf("\t 6. List all buttons\n");
- printf("\t 7. List all directional pads\n");
- printf("\t 8. List all axes\n");
- printf("\t 9. List all X-axes\n");
- printf("\t10. Get events (stop when Control key pressed)\n");
- printf("\t11. Suspend\n");
- printf("\t12. Resume\n");
- printf("\t13. Create needs\n");
- printf("\t14. Destroy needs\n");
- printf("\t15. Get needs events\n");
- printf("\t16. Configuration dialog\n");
- printf("\t17. Enable mouse and keyboard\n");
- printf("\t18. Disable mouse and keyboard\n");
- printf("\t19. Reinitialize ADB bus\n");
- printf("\t30. Allocate/Deallocate test\n");
- #if DEBUG_DRIVER
- printf("\t31. TestAllocatePushData test\n");
- #endif
- printf("\t32. TestArbitraryAllocate test\n");
- printf("\t33. TestAccelration\n");
-
- printf("\n\tSelection: ");
-
- Boolean keyboardEnabled = gKeyboardEnabled;
- if (keyboardEnabled)
- {
- EnableDeviceClass(kISpDeviceClass_Keyboard, false);
- }
-
- char theString[32];
- gets( theString );
- theChoice = atoi( theString );
-
- if (keyboardEnabled)
- {
- EnableDeviceClass(kISpDeviceClass_Keyboard, true);
- }
-
- printf("\n\n");
-
- switch( theChoice )
- {
- case 1:
- theDoneFlag = true;
- break;
-
- case 4:
- TestListOfDevices();
- break;
-
- case 5:
- TestListOfElements();
- break;
-
- case 6:
- TestListOfButtons();
- break;
-
- case 7:
- TestListOfDPads();
- break;
-
- case 8:
- TestListOfAxes();
- break;
-
- case 9:
- TestListOfXAxes();
- break;
-
- case 10:
- GetAndPrintEvents(NULL);
- break;
-
- case 11:
- TestSuspend();
- break;
-
- case 12:
- TestResume();
- break;
-
- case 13:
- TestCreateNeeds();
- break;
-
- case 14:
- TestDestroyNeeds();
- break;
-
- case 15:
- TestNeedsEvents();
- break;
-
- case 16:
- TestConfiguration();
- break;
-
- case 17:
- EnableDeviceClass(kISpDeviceClass_Mouse, true);
- EnableDeviceClass(kISpDeviceClass_Keyboard, true);
- break;
-
- case 18:
- EnableDeviceClass(kISpDeviceClass_Mouse, false);
- EnableDeviceClass(kISpDeviceClass_Keyboard, false);
- break;
-
- case 19:
- ADBReInit();
- break;
-
- case 30:
- TestAllocateDeallocate();
- break;
-
- #if DEBUG_DRIVER
- case 31:
- TestAllocatePushData();
- break;
- #endif
-
- case 32:
- TestArbitraryAllocate();
- break;
-
- case 33:
- TestAcceleration();
- break;
-
- default:
- printf("\nhuh?\n");
- break;
- }
-
- printf("\nThank you, please drive through.\n");
- }
- }
-